package com.gqb.nio;

import java.nio.ByteBuffer;

public class nioBufferReadOnly {
	public static void main(String[] args) {
		ByteBuffer buffer=ByteBuffer.allocate(10);
		for (int i = 0; i < buffer.capacity(); i++) {
			buffer.put((byte) (i+1));
		}
		buffer.flip();
		ByteBuffer bufferReadOnly=buffer.asReadOnlyBuffer();
		while(bufferReadOnly.hasRemaining()){
			System.out.println(bufferReadOnly.get());
		}
		buffer.put(1,(byte) 23);
		bufferReadOnly.flip();
		while(bufferReadOnly.hasRemaining()){
			System.out.println(bufferReadOnly.get());
		}
	}
}
